package com.example.bbs.domain.model;


import lombok.Data;

@Data
public class Page {
    private Integer page = 1;
    private Integer limit = 10;
    private Integer totalSize;
    private String path;

    public Integer getFrom() {
        if (page - 2 < 1) return 1;
        return page - 2;
    }

    public Integer getTo() {
        if (page + 2 > getTotalPage()) return getTotalPage();
        return page + 2;
    }

    public Integer getTotalPage() {
        if (totalSize % limit == 0) return totalSize / limit;
        return totalSize / limit + 1;
    }

    public Integer getOffset() {
        return limit * page - limit;
    }
}
